<?php 
use \PsiFramework\Classes\Util\UI\Printer;
use \PsiFramework\Classes\Util\UI\HTML;
use \PsiFramework\Classes\Factory\DAOFactory;

$category = $response->getAttribute("category");
$entry = $response->getAttribute("entry");
$theme = $response->getAttribute("form");
$independantForm = $response->getAttribute("formId");

$categoryLink = '' ;
if (!is_null($category)) $categoryLink = '&category_id=' . $category->getId();
?>
<aside id="cont-gauche">
    <div class="bloc bloc-menu-1">
        <h2>
            <?php Printer::display($languageManager->getText('UPDATES')); ?>
        </h2>
        <nav>
            <ul>
                <li <?php if (isNullOrEmptyString($theme) && $independantForm == 'entry') echo 'class="actif"' ; ?>>
                    <a href="<?php
                             Printer::display(
                                 HTML::linkHref(
                                     "action=EditProfile&entry_id=".$entry->getId().'&form_id=entry'.$categoryLink
                                 )
                             ); ?>">
                        <span>&diamond;</span>
                        <?php Printer::display($languageManager->getText('GENERAL_INFORMATION')); ?>
                    </a>
                </li>
                <?php 
                $profile = $entry->getCategory()->getProfile();
                $profile->getParts();
                $parts = $profile->sortParts();

                for ($i = 0 ; $i<count($parts); $i++) {
                    $part = $parts[$i] ;
                    $curTheme = $part->getTheme();
                    
                    $responseIdDao = DAOFactory::getDAO('ResponseId');
                    $responseId = $responseIdDao->retrieveByEntryAndTheme($entry, $curTheme);
                ?>
                <li <?php if (!is_null($theme) && $curTheme==$theme) echo 'class="actif"' ; ?>>
                    <?php
                    $themeLink
                        = HTML::linkHref(
                            "action=EditProfile&entry_id=".$entry->getId().
                            "&form_id=".$curTheme->getId().$categoryLink
                        );
                    $locked = false ;
                    if (!is_null($responseId) && !$responseId->isActive() && !$part->isFree()) {
                        $locked = true;
                        $themeLink
                            = HTML::linkHref(
                        		"action=ShowTheme&entry_id=".$entry->getId().
                                "&form_id=".$curTheme->getId()
                            );
                    }
                    ?>
                    <a href="<?php Printer::display($themeLink); ?>">
                        <span>&diamond;</span>
                        <?php Printer::display($languageManager->getText($curTheme->getTitle())); ?>
                    </a>
                    <?php
                    if ($locked) {
                    ?>
                    <!-- insertion du verrou -->
					<span class="verrou">
                        <span class="bulle-info haut">
						    <?php Printer::display($languageManager->getText('CLICK_TO_UNLOCK')); ?>
						    <span class="bulle-fleche"></span>
						</span>
					</span>
                    <?php 
                    }
                    ?>
                </li>
                <?php
                }
                ?>
            </ul>
        </nav>
    </div>
    <div class="bloc">
        <?php echo HTML::link($languageManager->getText('ALLOMEDIA_RETURN_TO_INDEX'), '', array('class'=>'btn')); ?>
    </div>
</aside>
